const fs = require("fs");
const path = require("path");
const rootPath = require("../../config");

const ORIGIN = "gitTempOrigin";
const PAGEDEST = "pageDestination";
const STOREDEST = "storeDestination";
const CPNSDEST = "componentsDestination";
const KEY = { ORIGIN, PAGEDEST, STOREDEST, CPNSDEST };
class Manager {
	constructor() {
		this.instance = require("../config/index.json");
		this.KEY = KEY;
	}
	set(key, data) {
		this.instance[key] = data;
		try {
			fs.writeFileSync(
				path.resolve(rootPath.root, "lib/config/index.json"),
				JSON.stringify(this.instance)
			);
		} catch (e) {
			console.log(e);
		}
	}
	get(key) {
		if (this.instance[key]) {
			return this.instance[key];
		}
	}
	getAll() {
		return this.instance;
	}
}

module.exports = new Manager();
